#ifndef __GLF_TASK_TASKGROUPS_IMPL_H_INCLUDED__
#define __GLF_TASK_TASKGROUPS_IMPL_H_INCLUDED__

#include <glf/task/taskGroups.h>
#include <glf/task/taskHandler.h>

namespace glf {

template <typename Tag1>
void TaskGroupScope::Wait()
{
	task_detail::Group* group = GetGroup();
	TaskHandler<Tag1> th1;
	while(HasPendingTask(group))
	{
		if(th1.Consume() == false)
		{
			Thread::Sleep(0);
		}
	}
}

template <typename Tag1, typename Tag2>
void TaskGroupScope::Wait()
{
	task_detail::Group* group = GetGroup();
	TaskHandler<Tag1> th1;
	TaskHandler<Tag2> th2;

	while(HasPendingTask(group))
	{
		if(th1.Consume() == false)
		{
			if(th2.Consume() == false)
			{
				Thread::Sleep(0);
			}
		}
	}
}

} // end namespace glf

#endif // __GLF_TASK_TASKGROUPS_IMPL_H_INCLUDED__